google.load('jquery', '1.4.2');
google.load('jqueryui', '1.8.14');
google.setOnLoadCallback(function () {
    //Tab List
    var wrapper = '.widget_block';
    var header = 'h2';
    var content = '.widget';
    $('.widget_block').removeClass('tablist');
    $('.nowidget').addClass('tablist');
    var title = wrapper + ' ' + header;
    var container_to_hide = wrapper + ' ' + content;
    disable = false;
    $(title).css({
        display: 'none'
    }).each(

    function (i) {
        if (i == 0) {
            $(wrapper).prepend('<a href="/" class="widgettitle advanced_link active">' + $(this).html() + '</a>');
        }
        else {
            $('.advanced_link:last').after('<a href="/"class="widgettitle advanced_link">' + $(this).html() + '</a>');
        }
    });
    $(container_to_hide).each(

    function (i) {
        $(this).addClass('tablist list_' + i);
        if (i != 0) {
            $(this).css({
                display: 'none'
            });
        }
    });
    $('.advanced_link').each(

    function (i) {
        $(this).bind('click', function () {
            if ($(this).hasClass('active')) {
                return false
            }
            if (disable == false) {
                disable = true;
                $('.advanced_link').removeClass('active');
                $(this).addClass('active');
                $(container_to_hide + ':visible').slideUp(400, function () {
                    $('.list_' + i).slideDown(400, function () {
                        disable = false;
                    });
                });
            }
            return false;
        });
    });
    //Float BoxShare
    var offset = $('#boxShare').offset();
    var topPadding = 10;
    $(window).scroll(function () {
        if ($(window).scrollTop() > offset.top) {
            $('#boxShare').stop().animate({
                marginTop: $(window).scrollTop() - offset.top + topPadding
            });
        }
        else {
            $('#boxShare').stop().animate({
                marginTop: 0
            });
        };
    });
    //Switch View
    $('a.switchview').click(function () {
        $(this).toggleClass('on');
        $('.entrys').toggleClass('putih');
        return false
    });
    //Scroll to Top
    $('a[href=#main-wrap]').click(function () {
        $('html, body').animate({
            scrollTop: 0
        }, 'slow');
        return false;
    });
    //Navigation Menu
    if (!jQuery.browser.msie) { // IE  - 2nd level Fix
        $('#nav ul').css({
            opacity: '0.95'
        });
    }
    $('#nav a').removeAttr('title');
    $('#nav ul').css({
        display: 'none'
    }); // Opera Fix
    $('#nav > li > ul').parent().find('a:first').append('<span class="sub_list">&nbsp;</span>');
    $('#nav ul li > ul').parent().find('a:first').append('<span class="sub_sub_list">&nbsp;</span>');
    $('#nav li').hover(function () {
        $(this).find('ul:first').css({
            visibility: 'visible',
            display: 'none'
        }).show(400);
    }, function () {
        $(this).find('ul:first').css({
            visibility: 'hidden'
        });
    });
    //Search Panel
    var searchpanel = $('.noscript').html();
    $('.noscript').remove();
    $('#top').prepend('<span class="searchpanel_scroll" title="Search Site"></span><div class="searchpanel"><div class="adjustor">' + searchpanel + '</div></div>');
    $('.searchpanel_scroll').click(function () {
        $('.searchpanel').slideToggle('slow');
        $(this).toggleClass('active');
    });
    //Footer Slide
    var footer = $('.footer').html();
    $('.footer ul').remove();
    $('#top').prepend('<span class="footer_scroll" title="Browse Archives"></span><div class="footer advanced_footer"><div class="footer_bg">' + footer + '</div></div>');
    $('.advanced_footer .footer_meta').remove();
    $('.advanced_footer').css({
        opacity: 0.97
    });
    $('.footer_scroll').click(function () {
        $('.advanced_footer').slideToggle('slow');
        $(this).toggleClass('active');
    });
    //Teaser Box
    offset = $('.infowrap').offset();
    scrolling_area = $('.infowrap ul').height() - $('.infowrap').height();
    var SCROLL_FIX = $('.infowrap').height();
    var scroll_amount = 0;
    var currentPos = $('.infowrap ul').position();
    var animating = false;
    var ticker = 0;
    var height_of_rest = 0;
    var prevurl;
    $('.teaserbox').prepend('<span><a href="" title="">visit this site</a></span>');
    prevurl = $('.infowrap ul' + ' li:eq(0) a').attr('href');
    $('.teaserbox span a').attr({
        href: prevurl
    });
    $('.teaserbox span').click(function () {
        window.location = prevurl;
        return false;
    });
    $('.infowrap ul' + ' li:eq(' + ticker + ') a').addClass('ticker');
    $('.infowrap ul' + ' li a').each(function (i) {
        $(this).bind('click', function () {
            clearInterval(newsticker_interval);
            if (!($('.teaser_img_item_' + i).hasClass('displayme'))) {
                $('.displayme').fadeOut(400, function () {
                    $(this).removeClass('displayme');
                });
                $('.teaser_img_item_' + i).fadeIn(400).addClass('displayme');
                $('.teaser_excerpt_' + i).slideDown(600).addClass('displayme');
                prevurl = $('.infowrap ul' + ' li:eq(' + i + ') a').attr('href');
                $('.teaserbox span a').attr({
                    href: prevurl
                });
                $('.ticker').removeClass('ticker');
                $(this).addClass('ticker');
            }
            return false;
        });
    });

    function newsticker() {
        height_of_rest = 0;
        $('.infowrap ul' + ' li:gt(' + ticker + ')').each(function () {
            height_of_rest += $(this).height();
        });
        var amount_to_scroll;
        currentPos = $('.infowrap ul').position();
        if (height_of_rest >= $('.infowrap').height()) {
            amount_to_scroll = $('.infowrap ul' + ' li:eq(' + ticker + ')').height() - currentPos.top;
        }
        else {
            amount_to_scroll = $('.infowrap ul').height() - $('.infowrap').height();
        }
        if (ticker + 2 > $('.infowrap ul' + ' li').length) {
            amount_to_scroll = 0;
            ticker = -1;
        }
        if (scrolling_area > 0) {
            $('.infowrap ul').animate({
                top: -amount_to_scroll
            }, 250);
        }
        ticker++;
        $('.ticker').removeClass('ticker');
        prevurl = $('.infowrap ul' + ' li:eq(' + ticker + ') a').attr('href');
        $('.teaserbox span a').attr({
            href: prevurl
        });
        $('.infowrap ul' + ' li:eq(' + ticker + ') a').addClass('ticker');
        $('.displayme').fadeOut(600, function () {
            $(this).removeClass('displayme');
        });
        $('.teaser_img_item_' + ticker).fadeIn(400).addClass('displayme');
        $('.teaser_excerpt_' + ticker).slideDown(600).addClass('displayme');
    }
    newsticker_interval = setInterval(newsticker, 5000);
    if (scrolling_area > 0) {
        $('.teaser_infobox').append('<span class="scrollup disabled">UP</span><span class="scrolldown">DOWN</span>');
        $('.scrolldown').bind('click', function () {
            scroll_items('down', SCROLL_FIX)
        });
        $('.scrollup').bind('click', function () {
            scroll_items('up', SCROLL_FIX)
        });

        function scroll_items(direction, amount) {
            clearInterval(newsticker_interval);
            if (animating == false) {
                animating = true;
                currentPos = $('.infowrap ul').position();
                if (direction == 'down') {
                    if ((currentPos.top * -1) + amount < $('.infowrap ul').height() - $('.infowrap').height()) {
                        scroll_amount += amount;
                    }
                    else {
                        scroll_amount = $('.infowrap ul').height() - $('.infowrap').height();
                        $('.scrolldown').addClass('disabled');
                    }
                    $('.scrollup').removeClass('disabled');
                }
                else if (direction == 'up') {
                    if (scroll_amount - amount >= 0) {
                        scroll_amount -= amount;
                    }
                    else {
                        scroll_amount = 0;
                        $('.scrollup').addClass('disabled');
                    }
                    $('.scrolldown').removeClass('disabled');
                }
                $('.infowrap ul').animate({
                    top: -scroll_amount
                }, 290, function () {
                    animating = false;
                });
            }
        }
    }
    //Overlay Image
    $('a.boxoverlay').each(function () {
        var altText = $(this).find('img').attr('alt');
        var img_src = $(this).find('img').attr('src').replace('s400', 's800');
        $(this).find('img').removeAttr('style').attr('src', img_src);
        $(this).wrap('<div id="boxoverlay"></div>');
        $(this).parent().append('<span><img src="https://lh4.googleusercontent.com/-ELEmc5D901Y/Ti1KZlTgIvI/AAAAAAAABUU/gL7010razK8/s800/tooltiptrans.png" alt="" /></span>');
        $(this).wrap('<div></div>');
        $(this).prepend('<span class="dark-background">' + altText + '</span>');
    });
    //Hover Zoom Image
    $('#boxoverlay div').mouseenter(function (e) {
        $(this).children('a').children('img').animate({
            height: '218',
            left: '0',
            top: '0',
            width: '505'
        }, 500);
        $(this).children('a').children('span').fadeIn(200);
    }).mouseleave(function (e) {
        $(this).children('a').children('img').animate({
            height: '320',
            left: '-50',
            top: '-50',
            width: '700'
        }, 500);
        $(this).children('a').children('span').fadeOut(200);
    });
});
//Teaser JSON
gbrslide = new Array();
gbrslide[0] = "https://lh5.googleusercontent.com/_xcD4JK_dIjU/TcDEIEGszoI/AAAAAAAAFGk/FJ0gudNGxyA/s800/slide_revo_one.jpg";
showRandomImg = true;
summaryPost = 180;
jmlslidepost = 5;

function removeHtmlTag(strx, chop) {
    var s = strx.split("<");
    for (var i = 0; i < s.length; i++) {
        if (s[i].indexOf(">") != -1) {
            s[i] = s[i].substring(s[i].indexOf(">") + 1, s[i].length)
        }
    }
    s = s.join("");
    s = s.substring(0, chop - 1);
    return s
}

function teaserslidebox(json) {
    j = (showRandomImg) ? Math.floor((gbrslide.length + 1) * Math.random()) : 0;
    img = new Array();
    for (var i = 0; i < jmlslidepost; i++) {
        var entry = json.feed.entry[i];
        var posttitle = entry.title.$t;
        var pcm;
        var posturl;
        if (i == json.feed.entry.length) break;
        for (var k = 0; k < entry.link.length; k++) {
            if (entry.link[k].rel == 'alternate') {
                posturl = entry.link[k].href;
                break
            }
        }
        for (var k = 0; k < entry.link.length; k++) {
            if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
                pcm = entry.link[k].title.split("")[0];
                break
            }
        }
        if ("content" in entry) {
            var postcontent = entry.content.$t
        }
        else if ("summary" in entry) {
            var postcontent = entry.summary.$t
        }
        else var postcontent = "";
        postdate = entry.published.$t;
        if (j > gbrslide.length - 1) j = 0;
        img[i] = gbrslide[j];
        s = postcontent;
        a = s.indexOf("<img");
        b = s.indexOf("src=\"", a);
        c = s.indexOf("\"", b + 5);
        d = s.substr(b + 5, c - b - 5);
        if ((a != -1) && (b != -1) && (c != -1) && (d != "")) img[i] = d;
        var teaserimg = '<a href="' + posturl + '" class="teaser_img_item_' + i + '"><img src="' + img[i] + '"/></a>';
        var teaserart = '<div class="teaser_excerpt_' + i + ' teaser_excerpt"><div><strong>' + posttitle + '</strong><p>' + removeHtmlTag(postcontent, summaryPost) + '...</p></div></div>';
        document.write(teaserimg);
        document.write(teaserart);
        j++
    }
}

function teaserslideinfo(json) {
    for (var i = 0; i < jmlslidepost; i++) {
        var entry = json.feed.entry[i];
        var label = json.feed.entry[i].category[0].term;
        var posttitle = entry.title.$t;
        var posturl;
        var postauthor = entry.author[0].name.$t;
        var postdate = entry.published.$t;
        var tahun = postdate.substring(0, 4);
        var bulan = postdate.substring(5, 7);
        var hari = postdate.substring(8, 10);
        var namabulan = new Array();
        namabulan[1] = "Januari";
        namabulan[2] = "Pebruari";
        namabulan[3] = "Maret";
        namabulan[4] = "April";
        namabulan[5] = "Mei";
        namabulan[6] = "Juni";
        namabulan[7] = "Juli";
        namabulan[8] = "Agustus";
        namabulan[9] = "September";
        namabulan[10] = "Oktober";
        namabulan[11] = "November";
        namabulan[12] = "Desember";
        for (var k = 0; k < entry.link.length; k++) {
            if (entry.link[k].rel == 'alternate') {
                posturl = entry.link[k].href;
                break
            }
        }
        var teaserinfo = '<li><a href="' + posturl + '" rel="bookmark" class="teaser_list_item_' + i + '">' + posttitle + '<span>' + postauthor + ', ' + label + ', ' + hari + ' ' + namabulan[parseInt(bulan, 10)] + ' ' + tahun + '</span></a></li>';
        document.write(teaserinfo);
    }
}
var relnojudul = 0;
var relmaxtampil = 10;
var numchars = 180;
var morelink = "readmore";
var reljudul = new Array();
var relurls = new Array();
var relcuplikan = new Array();
var relgambar = new Array();

function saringtags(suchas, panjang) {
    var cuplik = suchas.split("<");
    for (var i = 0; i < cuplik.length; i++) {
        if (cuplik[i].indexOf(">") != -1) {
            cuplik[i] = cuplik[i].substring(cuplik[i].indexOf(">") + 1, cuplik[i].length)
        }
    }
    cuplik = cuplik.join("");
    cuplik = cuplik.substring(0, panjang - 1);
    return cuplik
}

function relpostimgcuplik(json) {
    for (var i = 0; i < json.feed.entry.length; i++) {
        var entry = json.feed.entry[i];
        reljudul[relnojudul] = entry.title.$t;
        postcontent = "";
        if ("content" in entry) {
            postcontent = entry.content.$t
        }
        else if ("summary" in entry) {
            postcontent = entry.summary.$t
        }
        relcuplikan[relnojudul] = saringtags(postcontent, numchars);
        if ("media$thumbnail" in entry) {
            postimg = entry.media$thumbnail.url
        }
        else {
            postimg = "http://lh3.ggpht.com/_xcD4JK_dIjU/SnamIh0KTCI/AAAAAAAADMA/hLjqmEbdtkw/d/noimagethumb.gif"
        }
        relgambar[relnojudul] = postimg;
        for (var k = 0; k < entry.link.length; k++) {
            if (entry.link[k].rel == 'alternate') {
                relurls[relnojudul] = entry.link[k].href;
                break
            }
        }
        relnojudul++
    }
}

function contains(a, e) {
    for (var j = 0; j < a.length; j++) if (a[j] == e) return true;
    return false
}

function artikelterkait() {
    var tmp = new Array(0);
    var tmp2 = new Array(0);
    var tmp3 = new Array(0);
    var tmp4 = new Array(0);
    for (var i = 0; i < relurls.length; i++) {
        if (!contains(tmp, relurls[i])) {
            tmp.length += 1;
            tmp[tmp.length - 1] = relurls[i];
            tmp2.length += 1;
            tmp2[tmp2.length - 1] = reljudul[i];
            tmp3.length += 1;
            tmp3[tmp3.length - 1] = relcuplikan[i];
            tmp4.length += 1;
            tmp4[tmp4.length - 1] = relgambar[i]
        }
    }
    reljudul = tmp2;
    relurls = tmp;
    relcuplikan = tmp3;
    relgambar = tmp4;
    for (var i = 0; i < reljudul.length; i++) {
        var informasi = Math.floor((reljudul.length - 1) * Math.random());
        var tempJudul = reljudul[i];
        var tempUrls = relurls[i];
        var tempCuplikan = relcuplikan[i];
        var tempGambar = relgambar[i];
        reljudul[i] = reljudul[informasi];
        relurls[i] = relurls[informasi];
        relcuplikan[i] = relcuplikan[informasi];
        relgambar[i] = relgambar[informasi];
        reljudul[informasi] = tempJudul;
        relurls[informasi] = tempUrls;
        relcuplikan[informasi] = tempCuplikan;
        relgambar[informasi] = tempGambar
    }
    var rangkumanPosts = 0;
    var r = Math.floor((reljudul.length - 1) * Math.random());
    var rini = r;
    var relhasil;
    var dirURL = document.URL;
    while (rangkumanPosts < relmaxtampil) {
        if (relurls[r] != dirURL) {
            relhasil = "<li class='news-title clearfix'>";
            relhasil += "<a href='" + relurls[r] + "' rel='nofollow'  target='_top' title='" + reljudul[r] + "'><img src='" + relgambar[r] + "' /></a>";
            relhasil += "<a href='" + relurls[r] + "' target='_top'>" + reljudul[r] + "</a>";
            relhasil += "<span class='news-text'>" + relcuplikan[r] + " ... [<a href='" + relurls[r] + "' target='_top'>" + morelink + "</a>]<span class='news-text'>";
            relhasil += "</li>";
            document.write(relhasil);
            rangkumanPosts++;
            if (rangkumanPosts == relmaxtampil) {
                break
            }
        }
        if (r < reljudul.length - 1) {
            r++
        }
        else {
            r = 0
        }
        if (r == rini) {
            break
        }
    }
}